package com.mangowang.module.main.holder;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.bigkoo.convenientbanner.holder.Holder;
import com.mangowang.lib.common.help.GlideHelper;
import com.mangowang.lib.common.proto.Index;
import com.mangowang.module.main.web.ui.WebViewActivity;
import com.mangowang.module.main.R;

public class BannerImageHoderView extends Holder<Index.get_show_list.List> {

    private ImageView imageView;
    private Context context;

    public BannerImageHoderView(Context context, View itemView) {
        super(itemView);
        this.context = context;
    }

    @Override
    protected void initView(View itemView) {
        imageView = itemView.findViewById(R.id.iv_banner);
    }

    @Override
    public void updateUI(Index.get_show_list.List data) {
        GlideHelper.INSTANCE.loadImage(context, imageView, data.getAdvCode());
        imageView.setOnClickListener(v -> {
            if (!TextUtils.isEmpty(data.getAdvId())) {  //  关联类型：0无跳转，1链接跳转，2视频详情页跳转
                if (data.getAdvId().startsWith("http")) {
                    WebViewActivity.startActivity(context, data.getAdvId());
                } else {
                    WebViewActivity.startActivity(context, data.getAdvId(), true);
                }

            }
        });
    }
}
